<include file="Public/min-header" />
<link href="__PUBLIC__/plugins/daterangepicker/daterangepicker-bs3.css" rel="stylesheet" type="text/css" />
<script src="__PUBLIC__/plugins/daterangepicker/moment.min.js" type="text/javascript"></script>
<script src="__PUBLIC__/plugins/daterangepicker/daterangepicker.js" type="text/javascript"></script>
<div class="wrapper">
    <include file="Public/breadcrumb" />
    <section class="content">
        <div class="container-fluid">
            <div class="pull-right">
                <a href="javascript:history.go(-1)" data-toggle="tooltip" title="" class="btn btn-default" data-original-title="返回"><i class="fa fa-reply"></i></a>
            </div>
            <div class="panel panel-default">
                <div class="panel-heading">
                    <h3 class="panel-title"><i class="fa fa-list"></i> 分成详情</h3>
                </div>
                <div class="panel-body ">
                    <ul class="nav nav-tabs">
                        <li class="active"><a href="#tab_tongyong" data-toggle="tab">获佣详情</a></li>
                    </ul>
                    <form method="post" id="editForm">
                        <!--通用信息-->
                        <div class="tab-content">                 	  
                            <div class="tab-pane active" id="tab_tongyong">

                                <table class="table table-bordered">
                                    <tbody>
                                        <tr>
                                            <td class = "text-right">获佣用户id</td>
                                            <td>
                                                <a href="{:U('Admin/User/detail',array('id'=>$bonusLog[user_id]))}">{$bonusLog[user_id]}</a>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td class = "text-right">获佣用户名</td>
                                            <td>
                                                {$bonusLog.nickname}
                                            </td>
                                        </tr>
                                        <tr>
                                            <td class = "text-right">获佣订单</td>
                                            <td>
                                                <a href="{:U('Admin/Order/detail',array('order_id'=>$bonusLog[order_id]))}">{$bonusLog.order_sn}</a>                                       
                                            </td>
                                        </tr>                                
                                        <tr>
                                            <td class = "text-right">获佣金额</td>
                                            <td>
                                                {$bonusLog.money}
                                            </td>
                                        </tr>        
                                        <tr>
                                            <td class = "text-right">获佣用户级别</td>
                                            <td>
                                                {$bonusLog.level}
                                            </td>
                                        </tr>        
                                        <tr>
                                            <td class = "text-right">分成记录生成时间</td>
                                            <td>
                                                {$bonusLog.create_time|date="Y-m-d H:i",###}
                                            </td>
                                        </tr>  
                                        <tr>
                                            <td class = "text-right">状态</td>
                                            <td>                                        
                                    <if condition="$bonusLog[status] eq 0">未付款</if>
                                    <if condition="$bonusLog[status] eq 1">已付款</if>
                                    <if condition="$bonusLog[status] eq 2">等待分成</if>
                                    <if condition="$bonusLog[status] eq 3">已分成</if>
                                    <if condition="$bonusLog[status] eq 4">已取消</if>                                                    
                                    </td>
                                    </tr>  
                                    <tr>
                                        <td class = "text-right">确定分成或者取消时间</td>
                                        <td>
                                            {$bonusLog.create_time|date="Y-m-d H:i",###}
                                        </td>
                                    </tr>                                                          
                                    <tr>
                                        <td class = "text-right">备注</td>
                                        <td>
                                            <textarea rows="4" cols="60" id="remark" name="remark" class = "form-control">{$bonusLog.remark}</textarea>
                                            <span id="err_remark" style="color:#F00; display:none;"></span>                                        
                                        </td>
                                    </tr>                                  
                                    </tbody>                                
                                </table>
                            </div>                           
                        </div>              
                        <div class="pull-right">
                            <input type="hidden" name="id" value="{$bonusLog.id}">
                            <input type="hidden" name="user_id" value="{$bonusLog.user_id}">                        
                            <input type="hidden" id="status" name="status" value="{$bonusLog[status]}">
                            <if condition="$bonusLog[status] eq 2">
                                <button class="btn btn-primary" data-toggle="tooltip" type="button" onclick="passBonus();">确定分成</button>                        
                                <button class="btn btn-primary" data-toggle="tooltip" type="button" onclick="refuseBonus();">取消分成</button>
                                <else />
                                <button class="btn btn-primary" data-toggle="tooltip" type='submit'>修改备注</button>
                            </if>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </section>
</div>
<script>
    // 确定分成
    function passBonus() {
        if (!confirm('金额将直接转入用户余额,确定要分成吗?'))
            return false;

        if ($.trim($('#remark').val()).length == 0)
        {
            alert('请填写分成备注');
            return false;
        }
        $('#status').val('3');
        $('#editForm').submit();

    }
    // 取消分成    
    function refuseBonus() {
        if (!confirm('确定要取消分成吗?'))
            return false;

        if ($.trim($('#remark').val()).length == 0)
        {
            alert('请填写取消备注');
            return false;
        }

        $('#status').val('4');
        $('#editForm').submit();

    }

</script>
</body>

</html>
